'use strict';

const Controller = require('../../../core/common');

class UserIntegralsController extends Controller {

  async index() {

    const { ctx } = this;

    const { userId } = ctx.params;

    const attributes = ['id', 'type', 'totalIn', 'amount', 'createdAt', 'updatedAt'];

    const data = await ctx.service.v1.userIntegrals.findAll({ attributes, where: { userId } });

    this.success(data);
  }

  async show() {

    const { ctx } = this;

    const { userId } = ctx.params;

    const params = { where: { userId } }

    const data = await ctx.service.v1.userIntegrals.findAll(params);

    this.success(data);
  }

  async show() {

    const { ctx } = this;

    const { id } = ctx.params;

    const data = await ctx.service.v1.userIntegrals.findById(id);

    this.success(data);
  }
}

module.exports = UserIntegralsController;